#ifndef ZTCPSERVER_H
#define ZTCPSERVER_H

#include <QTcpServer>
#include <QTcpSocket>
#include <QObject>
#include <QDebug>
#include <QDataStream>
#include <QMutex>
#include <QMutexLocker>

#include "ztcpdata.h"

class ZTcpServer : public QTcpServer
{
    Q_OBJECT
public:
    ZTcpServer(QObject *parent=nullptr);
    void push_back(QTcpSocket* tcpSocket);
    void removeOne(QTcpSocket* tcpSocket);
    const QList<QTcpSocket *> &listPTcpSocket() const;
    QStringList connectTcpSocketInfos();
    QString currentTcpSocketInfo(QTcpSocket* tcpSocket);
    void sendOtherTcpSocket(QTcpSocket *currentTcpSocket,ZTcpData data);
private slots:
    void slotNewConnection();
    void slotDisConnected();
    void slotReadyRead();
private:
    QList<QTcpSocket*> mListPTcpSocket;
    ZTcpData m_TcpData;
    QMutex m_Mutex;
};

#endif // ZTCPSERVER_H
